package com.xintonghua.hongyi;

import android.os.Bundle;
import android.widget.ImageView;

import com.xintonghua.base.ui.BaseActivity;
import com.xintonghua.base.ui.MySubscriber;
import com.xintonghua.hongyi.ui.MainActivity;
import com.xintonghua.hongyi.ui.user.LoginActivity;

import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;


public class WelcomeActivity extends BaseActivity {
    private final int defaultTime = 2;
    @BindView(R.id.iv_welcome)
    ImageView ivWelcome;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        ButterKnife.bind(this);
        timer();
    }

    /**
     * 定时器
     */
    private void timer() {
        Flowable.timer(defaultTime, TimeUnit.SECONDS)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new MySubscriber<Long>() {
                    @Override
                    public void next(Long aLong) {
                        openActivity(MainActivity.class);
                        finish();
                    }
                });


    }
}
